#include<stdio.h>
#include<string.h>
int a[120];
char b[1000];
void fun1(int* p, int m)
{
    int i, j, k;
    for (i = 0; i < m; i++)
    {
        for (j = 0; j < m; j++)
        {
            if (a[i] < a[j])
            {
                k = a[i];
                a[i] = a[j];
                a[j] = k;
            }
        }
    }
    for (i = 0; i < m; i++){
        printf("%d", a[i]);
        if (i != m - 1) printf(" ");
    }
}
void fun2(char* b)
{
    int i, j = 0;
    int sum = 0;
    for (i = 0; i < strlen(b); i++)
    {
        if (b[i] != '5')
        {
            sum = sum * 10 + (b[i] - '0');
        }
        else
        {
            if (b[i - 1] != '5' && i != 0)
            {
                a[j] = sum;
                j++;
                sum = 0;
            }
        }
    }
    if (b[i - 1] == '5') fun1(a, j);
    else
    {
        a[j] = sum;
        fun1(a, j + 1);
    }
}
int main()
{
    gets(b);
    fun2(b);
    return 0;
}